<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<jsp:include page="header.jsp">
	<jsp:param value="首页" name="title"/>
</jsp:include>
<link href="css/home.css" rel="stylesheet">
<script type="text/javascript">
	//websocket
	$(function() {
		console.log("abc");
		var ws = null;
		//判断当前浏览器是否支持WebSocket
		if('WebSocket' in window) {
			//判断请求是http还是https
			if ('https:' == document.location.protocol) {
				ws = new WebSocket("wss://localhost:8080/ownworld/websocket");
			} else {
				ws = new WebSocket("ws://localhost:8080/ownworld/websocket");
			}
			
		} else {
			alert('不支持webSocket');
		}
		ws.onopen = function() {
			console.log("onpen");
			ws.send("{}");
		}
		ws.onclose = function() {
			console.log("onclose");
		}

		ws.onmessage = function(msg) {
			console.log("msg.data:" + msg.data);
			$('#userNumSpan').html('在线人数为:' + msg.data);
		}
		
	})
</script>

<body>
您好，游客！如需享有更高权限，请充值VIP！
<a href="login/message">login/message</a>
<span id="userNumSpan">在线人数为:${userNum}</span>

<jsp:include page="user/userManager.jsp"></jsp:include>

</body>
</html>